#!/bin/bash

if [ -n "$2" ] ; then
  data_date=$2
else
  data_date=`date -d "-1 days" +%F`
fi

ods_event_app_log="
load data inpath '/warehouse/app_logs/${data_date}/*' into table jtp_app_ods.ods_event_app_log partition (dt = '${data_date}');
"
ods_md_areas="
load data inpath '/warehouse/app_basic/t_md_areas/${data_date}' overwrite into table jtp_app_ods.ods_md_areas partition (dt = '${data_date}');
"

case $1 in
"all")
/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${ods_event_app_log}${ods_md_areas}"
;;
"ods_event_app_log")
/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${ods_event_app_log}"
;;
"ods_md_areas")
/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${ods_md_areas}"
esac